/**
 * <copyright>
 * </copyright>
 *

 */
package scerbak.usecases.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import scerbak.usecases.Actor;
import scerbak.usecases.Scope;
import scerbak.usecases.ScopeType;
import scerbak.usecases.UsecasesPackage;
import scerbak.usecases.Visibility;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Scope</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link scerbak.usecases.impl.ScopeImpl#getVisibility <em>Visibility</em>}</li>
 *   <li>{@link scerbak.usecases.impl.ScopeImpl#getType <em>Type</em>}</li>
 *   <li>{@link scerbak.usecases.impl.ScopeImpl#getInternalActor <em>Internal Actor</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope
{
  /**
   * The default value of the '{@link #getVisibility() <em>Visibility</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getVisibility()
   * @generated
   * @ordered
   */
  protected static final Visibility VISIBILITY_EDEFAULT = Visibility.BLACKBOX;

  /**
   * The cached value of the '{@link #getVisibility() <em>Visibility</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getVisibility()
   * @generated
   * @ordered
   */
  protected Visibility visibility = VISIBILITY_EDEFAULT;

  /**
   * The default value of the '{@link #getType() <em>Type</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getType()
   * @generated
   * @ordered
   */
  protected static final ScopeType TYPE_EDEFAULT = ScopeType.BUSINESS;

  /**
   * The cached value of the '{@link #getType() <em>Type</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getType()
   * @generated
   * @ordered
   */
  protected ScopeType type = TYPE_EDEFAULT;

  /**
   * The cached value of the '{@link #getInternalActor() <em>Internal Actor</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getInternalActor()
   * @generated
   * @ordered
   */
  protected Actor internalActor;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ScopeImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return UsecasesPackage.Literals.SCOPE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Visibility getVisibility()
  {
    return visibility;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setVisibility(Visibility newVisibility)
  {
    Visibility oldVisibility = visibility;
    visibility = newVisibility == null ? VISIBILITY_EDEFAULT : newVisibility;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, UsecasesPackage.SCOPE__VISIBILITY, oldVisibility, visibility));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ScopeType getType()
  {
    return type;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setType(ScopeType newType)
  {
    ScopeType oldType = type;
    type = newType == null ? TYPE_EDEFAULT : newType;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, UsecasesPackage.SCOPE__TYPE, oldType, type));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Actor getInternalActor()
  {
    return internalActor;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetInternalActor(Actor newInternalActor, NotificationChain msgs)
  {
    Actor oldInternalActor = internalActor;
    internalActor = newInternalActor;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, UsecasesPackage.SCOPE__INTERNAL_ACTOR, oldInternalActor, newInternalActor);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setInternalActor(Actor newInternalActor)
  {
    if (newInternalActor != internalActor)
    {
      NotificationChain msgs = null;
      if (internalActor != null)
        msgs = ((InternalEObject)internalActor).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - UsecasesPackage.SCOPE__INTERNAL_ACTOR, null, msgs);
      if (newInternalActor != null)
        msgs = ((InternalEObject)newInternalActor).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - UsecasesPackage.SCOPE__INTERNAL_ACTOR, null, msgs);
      msgs = basicSetInternalActor(newInternalActor, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, UsecasesPackage.SCOPE__INTERNAL_ACTOR, newInternalActor, newInternalActor));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case UsecasesPackage.SCOPE__INTERNAL_ACTOR:
        return basicSetInternalActor(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case UsecasesPackage.SCOPE__VISIBILITY:
        return getVisibility();
      case UsecasesPackage.SCOPE__TYPE:
        return getType();
      case UsecasesPackage.SCOPE__INTERNAL_ACTOR:
        return getInternalActor();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case UsecasesPackage.SCOPE__VISIBILITY:
        setVisibility((Visibility)newValue);
        return;
      case UsecasesPackage.SCOPE__TYPE:
        setType((ScopeType)newValue);
        return;
      case UsecasesPackage.SCOPE__INTERNAL_ACTOR:
        setInternalActor((Actor)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case UsecasesPackage.SCOPE__VISIBILITY:
        setVisibility(VISIBILITY_EDEFAULT);
        return;
      case UsecasesPackage.SCOPE__TYPE:
        setType(TYPE_EDEFAULT);
        return;
      case UsecasesPackage.SCOPE__INTERNAL_ACTOR:
        setInternalActor((Actor)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case UsecasesPackage.SCOPE__VISIBILITY:
        return visibility != VISIBILITY_EDEFAULT;
      case UsecasesPackage.SCOPE__TYPE:
        return type != TYPE_EDEFAULT;
      case UsecasesPackage.SCOPE__INTERNAL_ACTOR:
        return internalActor != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (visibility: ");
    result.append(visibility);
    result.append(", type: ");
    result.append(type);
    result.append(')');
    return result.toString();
  }

} //ScopeImpl
